package com.myzhouye.biz.model;/***
 *                    _ooOoo_
 *                   o8888888o
 *                   88" . "88
 *                   (| -_- |)
 *                    O\ = /O
 *                ____/`---'\____
 *              .   ' \\| |// `.
 *               / \\||| : |||// \
 *             / _||||| -:- |||||- \
 *               | | \\\ - /// | |
 *             | \_| ''\---/'' | |
 *              \ .-\__ `-` ___/-. /
 *           ___`. .' /--.--\ `. . __
 *        ."" '< `.___\_<|>_/___.' >'"".
 *       | | : `- \`.;`\ _ /`;.`/ - ` : | |
 *         \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 *                    `=---='
 *
 * .............................................
 *          佛祖保佑             永无BUG
 */

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.*;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @program: game01
 * @description:
 * @author: 那条蠢鱼
 * @create: 2025-11-05 13:23
 **/
@Entity
@Table(name = "user")
@Data
@Schema(name = "用户信息")
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Schema(description = "用户ID")
    private Long id;

    @Column(nullable = false, unique = true)
    @Schema(description = "用户名（登录账号）")
    private String username;

    @Column(nullable = false)
    @Schema(description = "用户昵称")
    private String nickname;

    @Column(nullable = false)
    @Schema(description = "密码（加密存储）")
    private String password;

    @Column(nullable = false, precision = 12, scale = 2)
    @Schema(description = "钱包余额（货币单位）")
    private BigDecimal walletBalance = BigDecimal.ZERO; // 默认为0

    @Column(name = "created_at", updatable = false)
    @Schema(description = "创建时间")
    private LocalDateTime createdAt = LocalDateTime.now(); // 自动填充创建时间

    @Column(name = "updated_at")
    @Schema(description = "更新时间")
    private LocalDateTime updatedAt;

    @PreUpdate
    public void preUpdate() {
        this.updatedAt = LocalDateTime.now(); // 更新时自动刷新时间
    }
}
